//
//  ByFootBallListBottomView.m
//  caipiao_ios
//
//  Created by mc on 2018/7/27.
//  Copyright © 2018年 ZhangZhanbin. All rights reserved.
//

#import "ByFootBallListBottomView.h"

@implementation ByFootBallListBottomView

- (id)init{
    self = [super init];
    if (self) {
        
        CGFloat width = SCREEN_WIDTH / 2.0;
        
        self.backgroundColor = [UIColor whiteColor];
        UIButton *sureBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self addSubview:sureBtn];
        [sureBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(0);
            make.bottom.equalTo(self).offset(0);
            make.height.mas_equalTo(@49);
            make.width.mas_equalTo(@(width));
        }];
        sureBtn.backgroundColor = BY_THEME_COLOR;
        [sureBtn setTitle:@"投注" forState:UIControlStateNormal];
        [sureBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        sureBtn.titleLabel.font = FONT(14);
        sureBtn.tag = 100;
        [sureBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
        self.sureBtn = sureBtn;
     
    
        UIButton *sureBtn1 = [UIButton buttonWithType:UIButtonTypeCustom];
        [self addSubview:sureBtn1];
        [sureBtn1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(0);
            make.bottom.equalTo(self).offset(0);
            make.height.mas_equalTo(@49);
            make.width.mas_equalTo(@(width));
        }];
        sureBtn1.backgroundColor = rgba(237, 122, 19, 1);
        [sureBtn1 setTitle:@"发起跟单" forState:UIControlStateNormal];
        [sureBtn1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        sureBtn1.titleLabel.font = FONT(14);
        sureBtn1.tag = 200;
        [sureBtn1 addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
        self.sureBtn1 = sureBtn1;
        

        UILabel *moneyLabel = [[UILabel alloc] init];
        [self addSubview:moneyLabel];
        [moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(-10);
            make.top.equalTo(self).offset(5);
            make.left.equalTo(self).offset(SCREEN_WIDTH / 2 + 10);
            make.height.mas_equalTo(@18);
        }];
        moneyLabel.text = @"2元";
        moneyLabel.font = FONT(16);
        moneyLabel.textColor = BY_THEME_COLOR;
        moneyLabel.textAlignment = NSTextAlignmentLeft;
        self.moneyLabel = moneyLabel;
        
        UILabel *otherLabel = [[UILabel alloc] init];
        [self addSubview:otherLabel];
        [otherLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(0);
            make.right.equalTo(sureBtn1.mas_right).offset(-10);
            make.top.equalTo(moneyLabel.mas_top).offset(2);
            make.height.mas_equalTo(@15);
        }];
        otherLabel.font = FONT(12);
        otherLabel.textColor = BY_TEXT_COLOR;
        otherLabel.text = @"1注1倍";
        otherLabel.textAlignment = NSTextAlignmentRight;
        self.otherLabel = otherLabel;
        
        
        UILabel *notesLabel = [[UILabel alloc] init];
        [self addSubview:notesLabel];
        [notesLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(100);
            make.right.equalTo(self).offset(-100);
            make.bottom.equalTo(sureBtn.mas_top).offset(-5);
            make.height.mas_equalTo(@15);
        }];
        notesLabel.textColor = [UIColor grayColor];
        notesLabel.font = FONT(12);
        notesLabel.text = @"预计奖金";
        notesLabel.textAlignment = NSTextAlignmentCenter;
        notesLabel.adjustsFontSizeToFitWidth = YES;
        notesLabel.hidden = YES;
        self.notesLabel = notesLabel;
        
        
        UIControl *control = [[UIControl alloc] init];
        [self addSubview:control];
        [control mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(14);
            make.top.equalTo(self).offset(5);
            make.size.mas_equalTo(CGSizeMake(80, 30));
        }];
        control.userInteractionEnabled = YES;
        [control addTarget:self action:@selector(controlAction:) forControlEvents:UIControlEventTouchUpInside];
        
        UIButton *smallView = [[UIButton alloc] init];
        [control addSubview:smallView];
        [smallView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(control).offset(0);
            make.centerY.equalTo(control).offset(0);
            make.size.mas_equalTo(CGSizeMake(20, 20));
        }];
        
        [smallView setImage: [UIImage imageNamed:@"jiangjinyouhua"] forState:UIControlStateNormal];
        [smallView addTarget:self action:@selector(controlAction:) forControlEvents:UIControlEventTouchUpInside];
        
        UILabel *titleLabel = [[UILabel alloc] init];
        [control addSubview:titleLabel];
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(smallView.mas_right).offset(0);
            make.right.equalTo(control).offset(-10);
            make.centerY.equalTo(control).offset(0);
            make.height.mas_equalTo(@30);
        }];
        titleLabel.font = FONT(12);
        titleLabel.numberOfLines = 2;
        titleLabel.textAlignment = NSTextAlignmentCenter;
        titleLabel.text = @"奖金\n优化";
        titleLabel.textColor = BY_THEME_COLOR;
        
        
        
        
    }
    return self;
}

- (void)controlAction:(UIControl *)control{
    if (self.bonusBlock) {
        self.bonusBlock();
    }
}


- (void)btnAction:(UIButton *)btn{
    if (btn.tag == 100) {
        if (self.sureBlock) {
            self.sureBlock();
        }
    }else if (btn.tag == 200){
        
        if (self.documentaryBlock) {
            self.documentaryBlock();
        }
    }
}


- (void)setIsBasketBall:(BOOL)isBasketBall{
    _isBasketBall = isBasketBall;
    if (_isBasketBall) {
        self.sureBtn1.hidden = YES;
        [self.sureBtn mas_updateConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(@(SCREEN_WIDTH));
        }];
    }
}

@end
